#!/bin/bash
docker_version='28.0.1'
echo "##################开始安装$docker_version################"
#3.1 下载docker
#docker_version='28.0.1'
#ls docker-$docker_version.tgz || wget https://download.docker.com/linux/static/stable/aarch64/docker-$docker_version.tgz
ls ls docker-$docker_version.tgz || wget https://gitee.com/AmazingBian/install/raw/master/docker-28.0.1.tgz
#wget https://download.docker.com/linux/static/stable/aarch64/docker-27.3.1.tgz
#3.2、解压下载好的压缩包
tar -zxvf docker-$docker_version.tgz -C /usr/local/

#3.3、移动解压出来的二进制文件到 /usr/bin 目录中
ln -s  /usr/local/docker/* /usr/bin/

cat>/usr/lib/systemd/system/docker.service<<'EOF'
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF


mkdir -p /etc/docker
cat>/etc/docker/daemon.json<<EOF
{
  "registry-mirrors": [
    "https://dockerproxy.com",
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com",
    "https://ccr.ccs.tencentyun.com"],
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

systemctl daemon-reload
systemctl start docker
#systemctl status docker
docker -v
docker ps -a && docker images

echo "############$docker_version安装完成###############"



echo "############开始安装docker-compose###############"

#3.1 下载docker-compose

#ls docker-compose-linux-aarch64 || wget https://github.com/docker/compose/releases/download/v2.37.1/docker-compose-linux-aarch64
ls docker-compose-linux-aarch64 || wget https://gitee.com/AmazingBian/install/raw/master/docker-compose-linux-aarch64
cp  docker-compose-linux-aarch64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

echo "############docker-compose安装完成###############"

